package com.diy.sigmund.diycommon.designpatterns.factorymethod.pizza2;

import java.util.Arrays;
import java.util.StringJoiner;

/**
 * @author ylm-sigmund
 * @since 2022/1/17 15:57
 */
public abstract class Pizza {

    String name;
    // 每个pizza都持有一组在准备时会用到的原料
    Dough dough;
    Sauce sauce;
    Veggies[] veggies;
    Cheese cheese;
    Pepperoni pepperoni;
    Clams clams;

    /**
     * 现在把prepare()声明成抽象，在这个方法中，我们需要收集pizza所需的原料。而这些原料必然是来自原料工厂
     */
    abstract void prepare();

    public void bake() {
        System.out.println("Bake for 25 minutes at 350");
    }

    public void cut() {
        System.out.println("Cutting the pizza into diagonal slices");
    }

    public void box() {
        System.out.println("Place pizza in official PizzaStore box");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", Pizza.class.getSimpleName() + "[", "]")
                .add("name='" + name + "'")
                .add("dough=" + dough)
                .add("sauce=" + sauce)
                .add("veggies=" + Arrays.toString(veggies))
                .add("cheese=" + cheese)
                .add("pepperoni=" + pepperoni)
                .add("clams=" + clams)
                .toString();
    }
}
